package com.yeban.javase.day02.test05;

/**
 * @Desc TODO
 * @Author yeban
 * @Date 2025/10/10
 * <p>
 * 2、定义一个怪兽类Monster，可以通过这个类创建怪兽角色
 * 属性：
 * 怪兽拥有名称name，等级level，血量blood，攻击力power，防御力defence，种族kind。
 * 方法：
 * 怪兽拥有基本攻击方法attack(Hero h)，死亡判定方法isDead()，获取怪兽信息的方法show()。
 */
public class Monster {

    private String name;        // 名称
    private int level;          // 等级
    private double blood;          // 血量
    private int power;        // 攻击力
    private int defence;        // 防御力
    private String kind;        // 种族

    public Monster() {
    }

    public Monster(String name, int level, int blood, int power, int defence, String kind) {
        this.name = name;
        this.level = level;
        this.blood = blood;
        this.power = power;
        this.defence = defence;
        this.kind = kind;
    }

    public void attack(Hero h) {    // 基本攻击方法
        int damage = power - h.getDefence();
        if(damage <= 0) {
            damage = 1;
        }
        h.setBlood(h.getBlood() - damage);
        System.out.println("【" + this.name + "】" + "对" + "【" + h.getName() +"】" + "造成了" + damage + "点伤害");

        if(h.getBlood() <= 0) {
            System.out.println("【" + h.getName() +"】" + "还有" + 0 + "滴血\n");
        } else {
            System.out.println("【" + h.getName() +"】" + "还有" + h.getBlood() + "滴血\n");
        }

    }

    public boolean isDead() {  // 死亡判定方法
        if(blood <= 0) {
            System.out.println("【" + this.name + "】"+ "怪兽死亡！");
            return true;
        }
        return false;
    }

    public void show() {    // 获取怪兽信息的方法
        System.out.println(this);
    }


    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        this.name = name;
    }

    /**
     * 获取
     * @return level
     */
    public int getLevel() {
        return level;
    }

    /**
     * 设置
     * @param level
     */
    public void setLevel(int level) {
        this.level = level;
    }

    /**
     * 获取
     * @return blood
     */
    public double getBlood() {
        return blood;
    }

    /**
     * 设置
     * @param blood
     */
    public void setBlood(double blood) {
        this.blood = blood;
    }

    /**
     * 获取
     * @return power
     */
    public int getPower() {
        return power;
    }

    /**
     * 设置
     * @param power
     */
    public void setPower(int power) {
        this.power = power;
    }

    /**
     * 获取
     * @return defence
     */
    public int getDefence() {
        return defence;
    }

    /**
     * 设置
     * @param defence
     */
    public void setDefence(int defence) {
        this.defence = defence;
    }

    /**
     * 获取
     * @return kind
     */
    public String getKind() {
        return kind;
    }

    /**
     * 设置
     * @param kind
     */
    public void setKind(String kind) {
        this.kind = kind;
    }

    public String toString() {
        return "Monster{name = " + name + ", level = " + level + ", blood = " + blood + ", power = " + power + ", defence = " + defence + ", kind = " + kind + "}";
    }
}
